package com.hbnu.practices01;

/**
 * 在控制台输出所有的水仙花数
 *
 * @author kittychen
 * @since 2025-09-09 11:24
 */
public class Practice01 {
    public static void main(String[] args) {
        // for循环实现
        extracted();

        // while循环实现
        extracted1();
    }

    private static void extracted1() {
        int i = 100;
        while (i < 1000) {
            int ge = i % 10;
            int shi = i / 10 % 10;
            int bai = i / 100;
            if (ge * ge * ge + shi * shi * shi + bai * bai * bai == i) {
                System.out.println(i);
            }
            i++;
        }
    }

    private static void extracted() {
        for (int i = 100; i < 1000; i++) {
            int ge = i % 10;
            int shi = i / 10 % 10;
            int bai = i / 100;
            if (ge * ge * ge + shi * shi * shi + bai * bai * bai == i) {
                System.out.println(i);
            }
        }
    }
}
